<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Go文件感知国产模型 - 重构版</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        .tab-content {
            display: none;
        }
        .tab-content.active {
            display: block;
        }
        .highlight {
            background-color: yellow;
            font-weight: bold;
        }
    </style>
</head>
<body class="bg-gray-100">
    <div class="container mx-auto px-4 py-8">
        <h1 class="text-3xl font-bold text-center mb-8 text-gray-800">Go文件感知国产模型 - 重构版</h1>
        
        <!-- 系统状态卡片 -->
        <div class="bg-white rounded-lg shadow-md p-6 mb-8">
            <h2 class="text-xl font-semibold mb-4 text-gray-800">系统状态</h2>
            <div class="grid grid-cols-2 md:grid-cols-4 gap-4">
                <div class="text-center">
                    <div class="text-2xl font-bold text-blue-600" id="totalFiles">0</div>
                    <div class="text-sm text-gray-600">总文件数</div>
                </div>
                <div class="text-center">
                    <div class="text-2xl font-bold text-green-600" id="indexedFiles">0</div>
                    <div class="text-sm text-gray-600">已索引文件</div>
                </div>
                <div class="text-center">
                    <div class="text-2xl font-bold text-purple-600" id="totalChunks">0</div>
                    <div class="text-sm text-gray-600">总分块数</div>
                </div>
                <div class="text-center">
                    <div class="text-2xl font-bold text-orange-600" id="indexedChunks">0</div>
                    <div class="text-sm text-gray-600">已索引分块</div>
                </div>
            </div>
        </div>

        <!-- 标签页导航 -->
        <div class="bg-white rounded-lg shadow-md mb-8">
            <div class="border-b border-gray-200">
                <nav class="flex space-x-8 px-6">
                    <button class="tab-btn py-4 px-1 border-b-2 border-blue-600 text-blue-600 font-medium" data-tab="search">
                        <i class="fas fa-search mr-2"></i>智能搜索
                    </button>
                    <button class="tab-btn py-4 px-1 text-gray-600 hover:text-blue-600 font-medium" data-tab="index">
                        <i class="fas fa-database mr-2"></i>索引管理
                    </button>
                    <button class="tab-btn py-4 px-1 text-gray-600 hover:text-blue-600 font-medium" data-tab="directories">
                        <i class="fas fa-folder mr-2"></i>目录管理
                    </button>
                    <button class="tab-btn py-4 px-1 text-gray-600 hover:text-blue-600 font-medium" data-tab="system">
                        <i class="fas fa-cog mr-2"></i>系统设置
                    </button>
                </nav>
            </div>

            <!-- 搜索标签页 -->
            <div id="search-tab" class="tab-content active p-6">
                <h3 class="text-lg font-semibold mb-4">智能搜索</h3>
                
                <!-- 搜索类型选择 -->
                <div class="mb-4">
                    <label class="block text-sm font-medium text-gray-700 mb-2">搜索类型</label>
                    <div class="flex space-x-4">
                        <label class="flex items-center">
                            <input type="radio" name="searchType" value="semantic" checked class="mr-2">
                            <span>语义搜索</span>
                        </label>
                        <label class="flex items-center">
                            <input type="radio" name="searchType" value="keyword" class="mr-2">
                            <span>关键词搜索</span>
                        </label>
                        <label class="flex items-center">
                            <input type="radio" name="searchType" value="regex" class="mr-2">
                            <span>正则表达式搜索</span>
                        </label>
                    </div>
                </div>

                <!-- 搜索输入 -->
                <div class="mb-4">
                    <label for="searchQuery" class="block text-sm font-medium text-gray-700 mb-2">搜索查询</label>
                    <input type="text" id="searchQuery" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="输入您的问题或描述">
                </div>

                <!-- 搜索参数 -->
                <div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-4">
                    <div>
                        <label for="searchLimit" class="block text-sm font-medium text-gray-700 mb-2">结果数量</label>
                        <input type="number" id="searchLimit" value="10" min="1" max="100" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
                    </div>
                    <div>
                        <label for="searchThreshold" class="block text-sm font-medium text-gray-700 mb-2">相似度阈值</label>
                        <input type="number" id="searchThreshold" value="0.5" min="0" max="1" step="0.1" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
                    </div>
                    <div>
                        <label for="fileTypes" class="block text-sm font-medium text-gray-700 mb-2">文件类型 (逗号分隔)</label>
                        <input type="text" id="fileTypes" placeholder="如: .go,.js,.py" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
                    </div>
                </div>

                <!-- 搜索按钮 -->
                <button id="searchBtn" class="bg-blue-600 text-white px-6 py-2 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500">
                    <i class="fas fa-search mr-2"></i>搜索
                </button>

                <!-- 搜索结果 -->
                <div id="searchResults" class="mt-8 hidden">
                    <h4 class="text-lg font-semibold mb-4">搜索结果</h4>
                    <div id="searchResultsContent"></div>
                </div>
            </div>

            <!-- 索引管理标签页 -->
            <div id="index-tab" class="tab-content p-6">
                <h3 class="text-lg font-semibold mb-4">索引管理</h3>
                
                <!-- 索引目录输入 -->
                <div class="mb-4">
                    <label for="indexDirectories" class="block text-sm font-medium text-gray-700 mb-2">索引目录 (每行一个)</label>
                    <textarea id="indexDirectories" rows="4" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="输入要索引的目录路径，每行一个"></textarea>
                </div>

                <!-- 索引选项 -->
                <div class="mb-4 space-y-2">
                    <label class="flex items-center">
                        <input type="checkbox" id="recursiveIndex" checked class="mr-2">
                        <span>递归索引子目录</span>
                    </label>
                    <label class="flex items-center">
                        <input type="checkbox" id="forceReindex" class="mr-2">
                        <span>强制重新索引</span>
                    </label>
                </div>

                <!-- 索引按钮 -->
                <div class="space-x-4">
                    <button id="startIndexBtn" class="bg-green-600 text-white px-6 py-2 rounded-md hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500">
                        <i class="fas fa-play mr-2"></i>开始索引
                    </button>
                    <button id="getStatusBtn" class="bg-blue-600 text-white px-6 py-2 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500">
                        <i class="fas fa-info-circle mr-2"></i>获取状态
                    </button>
                </div>

                <!-- 索引状态 -->
                <div id="indexStatus" class="mt-8 hidden">
                    <h4 class="text-lg font-semibold mb-4">索引状态</h4>
                    <div id="indexStatusContent" class="bg-gray-50 p-4 rounded-md"></div>
                </div>
            </div>

            <!-- 目录管理标签页 -->
            <div id="directories-tab" class="tab-content p-6">
                <h3 class="text-lg font-semibold mb-4">目录管理</h3>
                
                <!-- 添加目录 -->
                <div class="mb-6">
                    <div class="flex space-x-4">
                        <input type="text" id="directoryPath" placeholder="输入目录路径" class="flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
                        <button id="addDirectoryBtn" class="bg-green-600 text-white px-6 py-2 rounded-md hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500">
                            <i class="fas fa-plus mr-2"></i>添加目录
                        </button>
                    </div>
                </div>

                <!-- 目录列表 -->
                <div id="directoriesList"></div>
            </div>

            <!-- 系统设置标签页 -->
            <div id="system-tab" class="tab-content p-6">
                <h3 class="text-lg font-semibold mb-4">系统设置</h3>
                
                <!-- 系统信息 -->
                <div class="mb-6">
                    <h4 class="text-md font-semibold mb-2">系统信息</h4>
                    <div class="bg-gray-50 p-4 rounded-md">
                        <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                            <div>
                                <span class="text-sm text-gray-600">服务器状态:</span>
                                <span id="serverStatus" class="ml-2 font-medium">检查中...</span>
                            </div>
                            <div>
                                <span class="text-sm text-gray-600">Qdrant状态:</span>
                                <span id="qdrantStatus" class="ml-2 font-medium">检查中...</span>
                            </div>
                            <div>
                                <span class="text-sm text-gray-600">运行时间:</span>
                                <span id="systemUptime" class="ml-2 font-medium">-</span>
                            </div>
                        </div>
                        <div class="mt-4">
                            <button id="refreshSystemInfoBtn" class="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500">
                                <i class="fas fa-refresh mr-2"></i>刷新系统信息
                            </button>
                        </div>
                    </div>
                </div>

                <!-- 索引管理 -->
                <div class="mb-6">
                    <h4 class="text-md font-semibold mb-2">索引管理</h4>
                    <div class="space-y-4">
                        <button id="setIndexDirectoryBtn" class="bg-green-600 text-white px-4 py-2 rounded-md hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500">
                            设置索引目录
                        </button>
                        <button id="clearAllIndexBtn" class="bg-red-600 text-white px-4 py-2 rounded-md hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500">
                            清除所有索引分块
                        </button>
                        <button id="clearDirectoryIndexBtn" class="bg-orange-600 text-white px-4 py-2 rounded-md hover:bg-orange-700 focus:outline-none focus:ring-2 focus:ring-orange-500">
                            清除索引目录分块
                        </button>
                    </div>
                </div>

                <!-- 当前索引目录显示 -->
                <div class="mb-6">
                    <h4 class="text-md font-semibold mb-2">当前索引目录</h4>
                    <div class="bg-gray-50 p-4 rounded-md">
                        <span id="currentIndexDirectory" class="text-gray-700">-</span>
                    </div>
                </div>

                <!-- 操作结果 -->
                <div id="settingsOperationResult" class="hidden mt-4 p-4 bg-blue-50 border border-blue-200 rounded-md">
                    <div id="settingsOperationContent"></div>
                </div>
            </div>
        </div>
    </div>

    <!-- 引入模块化的JavaScript文件 -->
    <script src="/static/js/api-client.js"></script>
    <script src="/static/js/tab-manager.js"></script>
    <script src="/static/js/search-manager.js"></script>
    <script src="/static/js/index-manager.js"></script>
    <script src="/static/js/directory-manager.js"></script>
    <script src="/static/js/system-manager.js"></script>
    <script src="/static/js/modal-manager.js"></script>
    <script src="/static/js/app.js"></script>
</body>
</html>